package com.apollow.oschina.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.apollow.oschina.R;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Dragon on 2017/1/14.
 */

public abstract class BaseVPActivity extends AppCompatActivity {
    @BindView(R.id.vp_follw_fans)
    public ViewPager mVpFollwFans;
    @BindView(R.id.tab_layout)
    public TabLayout mTabLayout;
    @BindView(R.id.ll_back)
    LinearLayout mLlBack;
    @BindView(R.id.tv_title)
    TextView mTvTitle;
    private BaseActivityVPAdapter mVpAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_follow);
        ButterKnife.bind(this);
        mTvTitle.setText(setTitle("111"));
        mVpAdapter = new BaseActivityVPAdapter(getSupportFragmentManager(), mVpFollwFans, mTabLayout);
        setupTab(mVpAdapter);
    }

    // 设置标题
    protected abstract String setTitle(String text);

    //取得bundle对象
    public Bundle getBundle(String title) {
        Bundle bundle = new Bundle();
        bundle.putString("key", title);
        return bundle;
    }

    public Bundle getBundle(int title) {
        Bundle bundle = new Bundle();
        bundle.putString("key", title + "");
        return bundle;
    }

    protected abstract void setupTab(BaseActivityVPAdapter vpAdapter);

    @OnClick(R.id.ll_back)
    public void onClick() {
        finish();
    }
}
